﻿package mortal.game.view.signUp.view
{
    import __AS3__.vec.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.events.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.mvc.core.*;

    public class SignUpRewardDaySpr extends GSprite
    {
        private var _tagVec:Vector.<SignUpTotalDayTagSpr>;
        private var _currSelTag:SignUpTotalDayTagSpr;

        public function SignUpRewardDaySpr()
        {
            this._tagVec = new Vector.<SignUpTotalDayTagSpr>;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            var _loc_2:SignUpTotalDayTagSpr = null;
            super.createDisposedChildrenImpl();
            this.mouseEnabled = true;
            this.mouseChildren = true;
            var _loc_1:int = 0;
            while (_loc_1 < 7)
            {
                
                _loc_2 = UICompomentPool.getUICompoment(SignUpTotalDayTagSpr);
                _loc_2.x = 97 * _loc_1;
                _loc_2.y = 0;
                this.addChild(_loc_2);
                this._tagVec.push(_loc_2);
                this.pushUIToDisposeVec(_loc_2);
                _loc_1++;
            }
            this.addEventListener(MouseEvent.CLICK, this.onClickHandler);
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            if (event.target is SignUpTotalDayTagSpr)
            {
                this.switchTag(event.target as SignUpTotalDayTagSpr);
            }
            return;
        }// end function

        public function set data(param1:Object) : void
        {
            var _loc_3:int = 0;
            var _loc_2:* = param1 as Array;
            if (_loc_2)
            {
                _loc_3 = 0;
                while (_loc_3 < _loc_2.length)
                {
                    
                    this._tagVec[_loc_3].data = _loc_2[_loc_3];
                    _loc_3++;
                }
            }
            if (this._currSelTag)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.SignUpSwitchDayTag, this._currSelTag.signUpTotalDayData));
            }
            return;
        }// end function

        public function setDefaultTag(param1:int) : void
        {
            var _loc_2:SignUpTotalDayTagSpr = null;
            for each (_loc_2 in this._tagVec)
            {
                
                if (_loc_2.signUpTotalDayData.totalDayNum == param1)
                {
                    this.switchTag(_loc_2);
                }
            }
            return;
        }// end function

        private function switchTag(param1:SignUpTotalDayTagSpr) : void
        {
            if (this._currSelTag)
            {
                this._currSelTag.isSel = false;
            }
            this._currSelTag = param1;
            this._currSelTag.isSel = true;
            Dispatcher.dispatchEvent(new DataEvent(EventName.SignUpSwitchDayTag, this._currSelTag.signUpTotalDayData));
            return;
        }// end function

        public function get currSelTag() : SignUpTotalDayTagSpr
        {
            return this._currSelTag;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            if (this._currSelTag && !this._currSelTag.isDisposed)
            {
                this._currSelTag.dispose(param1);
            }
            this._tagVec.length = 0;
            this._currSelTag = null;
            return;
        }// end function

    }
}
